﻿var widgetRepository = {
    container: null,
    initial: function (_container) {
        this.container = _container;
    },
    load: function (_container, _loadCallBack) {
        this.initial(_container);
        $.get("AJAXFunc.aspx",
                    { method: "getWidgets" },
                    function (json) {
                        $(widgetRepository.container).html("");
                        $(eval(json)).each(function (i, n) {
                            var anchor = $('<a></a>').addClass("additem").attr("widgettypeid", n.ID).html(n.Title);
                            $("<div></div>").append(anchor).addClass("toolboxbodyitem").appendTo($(widgetRepository.container));
                        });
                        if (_loadCallBack != null) {
                            _loadCallBack(json);
                        }
                    }
            );
    }
};